<form id="user-offer-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <input type="hidden" name="order_id" value="{$order.id}">
    
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <i class="fa fa-users"></i> 人员管理 - 订单号：{$order.order_no}
            </h3>
        </div>
        <div class="panel-body">
            
            <!-- 人员分配表格 -->
            <div class="form-group">
                <label class="col-sm-2 control-label">人员分配：</label>
                <div class="col-sm-10">
                    <table class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th width="20%">专员类型</th>
                                <th width="50%">选择人员</th>
                                <th width="30%">当前状态</th>
                            </tr>
                        </thead>
                        <tbody>
                            {volist name="offers" id="offer"}
                            <tr>
                                <td>
                                    <strong>{$offer.position_text}</strong>
                                </td>
                                <td>
                                    <input type="hidden" name="offers[{$offer.position}][offer_status]" value="{$offer.offer_status}">
                                    <input type="hidden" name="offers[{$offer.position}][position]" value="{$offer.position}">
                                    {if condition="$offer.offer_status == 2"}
                                        <!-- 状态为2（已完成）时，显示已选择的人员，不可修改 -->
                                        <select class="form-control offer-select" name="offers[{$offer.position}][user_id]" disabled>
                                            <option value="{$offer.user_id}" selected>
                                                {$offer.user_name}
                                            </option>
                                        </select>
                                    {else /}
                                        <!-- 其他状态时，可以正常选择人员 -->
                                        <select class="form-control offer-select" name="offers[{$offer.position}][user_id]">
                                            <option value="">请选择{$offer.position_text}</option>
                                            {if condition="isset($offer.users) && !empty($offer.users)"}
                                                {volist name="offer.users" id="user"}
                                                <option value="{$user.id}" {if condition="$offer.user_id == $user.id"}selected{/if}>
                                                    {$user.username} {if condition="$user.nickname"}({$user.nickname}){/if}
                                                </option>
                                                {/volist}
                                            {else /}
                                                <option value="">暂无可用人员</option>
                                            {/if}
                                        </select>
                                    {/if}
                                </td>
                                <td>
                                    {if condition="$offer.user_id"}
                                        {if condition="$offer.offer_status == 0"}
                                            <span class="label label-default">{$offer.offer_status_text}</span>
                                        {elseif condition="$offer.offer_status == 1" /}
                                            <span class="label label-warning">{$offer.offer_status_text}</span>
                                        {elseif condition="$offer.offer_status == 2" /}
                                            <span class="label label-success">{$offer.offer_status_text}</span>
                                        {elseif condition="$offer.offer_status == 3" /}
                                            <span class="label label-danger">{$offer.offer_status_text}</span>
                                        {else /}
                                            <span class="label label-info">{$offer.offer_status_text}</span>
                                        {/if}
                                      
                                    {else /}
                                        <span class="label label-default">未分配</span>
                                    {/if}
                                </td>
                            </tr>
                            {/volist}
                        </tbody>
                    </table>
                </div>
            </div>

            <!-- 说明信息 -->
            <div class="alert alert-warning">
                <h4><i class="fa fa-exclamation-triangle"></i> 重要说明</h4>
                <ul>
                    <li><strong class="text-danger">必须为所有4种专员类型选择人员才能提交！</strong></li>
                    <li><strong>图像专员</strong>：负责图像处理和优化</li>
                    <li><strong>资料专员</strong>：负责资料收集和整理</li>
                    <li><strong>写作专员</strong>：负责文案撰写和编辑</li>
                    <li><strong>申报专员</strong>：负责申报材料准备和提交</li>
                    <li><strong>状态显示</strong>：待处理(灰色) → 进行中(黄色) → 已完成(绿色) / 已拒绝(红色)</li>
                    <li><strong>人员筛选</strong>：下拉列表只显示对应专员类型的用户</li>
                    <li><strong class="text-info">已完成状态</strong>：状态为"已完成"的专员类型不可修改人员分配</li>
                </ul>
            </div>

        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed">
                <i class="fa fa-save"></i> 提交
            </button>
            <button type="button" class="btn btn-default" onclick="parent.layer.closeAll();">
                <i class="fa fa-times"></i> 取消
            </button>
        </div>
    </div>
</form>

